<script src="<?php echo base_url()?>/public/assets/js/laydate/laydate.js" type="text/javascript"></script>
<div class="row">
	<div class="col-sm-12">
	    <div>
    		<a href="javascript:history.back();" class="btn btn-info_01 float_right btn_search">返回</a>
    	</div>
		<div class="space"></div>
        <form action="/admin/summarybook/resetbook" method="post" onsubmit=" return yanzheng()">
		<input type="hidden" value="update" name="form_submit" />
		<input type="hidden" value="<?php echo $book_id?>" name="book_id" />
		<table width="100%" class="table table-striped table-bordered table-hover" widtd="100%">
			<tr>
				  <td width="15%" height="30" widtd="15%">教师：</td>
				  <td width="85%" height="30" align="left" widtd="85%">
				  <select name="teacher_id" onchange="Teachertime(value)">
				  	<?php foreach ($teacher_list as $key=>$val){?>
				  	<option value="<?php echo $val['id']?>"><?php echo $val['name']?></option>
				  	<?php }?>
				  </select>
				  </td>
			  </tr>
			<tr>
			  <td height="30" widtd="15%">预约时间：</td>
			  <td height="30" align="left" widtd="85%">
			  <select name="book_date" onchange="gettime(value)">
			  
			  </select>
			  <select name="book_time">
			  
              </select></td>
		  </tr>
			<tr>
			  <td height="30" colspan="2"><div align="center"><input type="submit" value="提交" /></div></td>
		  </tr>
	  </table>
	  </form>
	</div>
</div>
<script>
function yanzheng(){
	
	if(!confirm('确定要修改吗？')){
		return false;
	}
}
var time_list = new Array();
/**
 * 获取教师时间
 */
function Teachertime(id){
		$.ajax({
    	    type : "get", 
    	    async:false, 
    	    url : "/admin/summarybook/Teachertime?teacher_id="+id, 
    	    dataType : "json", 
    	    success : function(data){
    		    if(data['code'] == 10){
    		    	var content = '';
    		    	var list = data['list'];
    		    	for(var i=0;i<list.length;i++){
    		    		content+= '<option value="'+list[i]['date']+'">'+list[i]['date']+'</option>';
    			    }
    			    $("[name='book_date']").html(content);
    			}else{
    				$("[name='book_date']").html('');
    				alert(data['msg']);
    			}
    	    }, 
    	    error:function(){
    	        alert('fail'); 
    	    } 
	});
}
function gettime(id){
	$.ajax({
	    type : "get", 
	    async:false, 
	    url : "/admin/summarybook/getsessiontime", 
	    dataType : "json", 
	    success : function(data){
	    	var content = '';
	    	var list = data[id]['list'];
	    	for(var i=0;i<list.length;i++){
	    		content+= '<option value="'+list[i]['work_time_start']+'-'+list[i]['work_time_end']+'">'+list[i]['work_time_start']+'-'+list[i]['work_time_end']+'</option>';
		    }
		    $("[name='book_time']").html(content);
	    }, 
	    error:function(){
	        alert('fail'); 
	    } 
});
}
window.onload=function (){
	$("[name='teacher_id']").val(<?php echo $book_info['teacher_id']?>);
	Teachertime(<?php echo $book_info['teacher_id']?>);
	gettime($("[name='book_date']").val());
}
</script>
<!--content-->